package zm.irc.message.processor;

import org.apache.log4j.Logger;

import zm.irc.client.IrcClient;
import zm.irc.ioc.annotation.Service;
import zm.irc.message.receive.IrcReceiveMessage;


@Service
public class PingTimeoutProcessor implements IrcMessageProcessor{
    private static final Logger log = Logger.getLogger(PingMessageProcessor.class);
    @Override
    public boolean processor(IrcClient client, IrcReceiveMessage receivedMsg) {

        /* Reconnect when the ping timeout message received.*/
        if( receivedMsg != null && receivedMsg.pingTimeoutMessage(client)){
            
            client.reconnect();
            log.error("Ping timeout ,Reconnect");
            return false;
        }else{
            return true;
        }

    }
}
